//
//  ZShowBigImage.m
//  DoctorFAQs
//
//  Created by zjq on 17/3/24.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZShowBigImage.h"
@interface ZShowBigImage ()<UIGestureRecognizerDelegate>
@property (nonatomic,strong) UIImageView * bigImageView;
@end
@implementation ZShowBigImage

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initlizeInterface];
    }
    return self;
}
- (void)setImageUrl:(NSString *)imageUrl {
    _imageUrl = imageUrl;
    [_bigImageView sd_setImageWithURL:[NSURL URLWithString:_imageUrl] placeholderImage:[UIImage imageNamed:@"Reference_picture"]];
}
- (void)initlizeInterface {
        self.backgroundColor = [UIColor colorWithRed:28/255.0 green:28/255.0 blue:28/255.0 alpha:0.4];
        [self addSubview:self.bigImageView];
        [_bigImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.width.equalTo(self);
            make.height.offset(300);
        }];
        [self addTheTap];
}
// 灰色部分手势
- (void)addTheTap {
    UITapGestureRecognizer *tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(event:)];
    tapGesture.delegate = self;
    [self addGestureRecognizer:tapGesture];
}
- (void)event:(UITapGestureRecognizer *)gesture {
    [self removeFromSuperview];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if ([touch.view isDescendantOfView:self.bigImageView]) {
        return NO;
    }
    return YES;
}

- (UIImageView *)bigImageView {
    if (_bigImageView) {
        return _bigImageView;
    }
    _bigImageView = [[UIImageView alloc] init];
    return _bigImageView;
}

@end
